package com.ruoyi.agriculture.knowledge.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.agriculture.knowledge.mapper.ZsCropVarietyMapper;
import com.ruoyi.agriculture.knowledge.domain.ZsCropVariety;
import com.ruoyi.agriculture.knowledge.service.IZsCropVarietyService;

/**
 * 品种信息Service业务层处理
 *
 * @author ruoyi
 * @date 2025-07-22
 */
@Service
public class ZsCropVarietyServiceImpl implements IZsCropVarietyService
{
    @Autowired
    private ZsCropVarietyMapper zsCropVarietyMapper;

    /**
     * 查询品种信息
     *
     * @param id 品种信息主键
     * @return 品种信息
     */
    @Override
    public ZsCropVariety selectZsCropVarietyById(Long id)
    {
        return zsCropVarietyMapper.selectZsCropVarietyById(id);
    }

    /**
     * 🔥 新增：根据品种名称查询品种信息
     *
     * @param varietyName 品种名称
     * @return 品种信息
     */
    @Override
    public ZsCropVariety selectZsCropVarietyByName(String varietyName)
    {
        return zsCropVarietyMapper.selectZsCropVarietyByName(varietyName);
    }

    /**
     * 查询品种信息列表
     *
     * @param zsCropVariety 品种信息
     * @return 品种信息
     */
    @Override
    public List<ZsCropVariety> selectZsCropVarietyList(ZsCropVariety zsCropVariety)
    {
        return zsCropVarietyMapper.selectZsCropVarietyList(zsCropVariety);
    }

    /**
     * 🔥 新增：搜索品种信息
     *
     * @param keyword 搜索关键词
     * @return 品种信息集合
     */
    @Override
    public List<ZsCropVariety> searchZsCropVariety(String keyword)
    {
        return zsCropVarietyMapper.searchZsCropVariety(keyword);
    }

    /**
     * 新增品种信息
     *
     * @param zsCropVariety 品种信息
     * @return 结果
     */
    @Override
    public int insertZsCropVariety(ZsCropVariety zsCropVariety)
    {
        zsCropVariety.setCreateTime(DateUtils.getNowDate());
        return zsCropVarietyMapper.insertZsCropVariety(zsCropVariety);
    }

    /**
     * 修改品种信息
     *
     * @param zsCropVariety 品种信息
     * @return 结果
     */
    @Override
    public int updateZsCropVariety(ZsCropVariety zsCropVariety)
    {
        zsCropVariety.setUpdateTime(DateUtils.getNowDate());
        return zsCropVarietyMapper.updateZsCropVariety(zsCropVariety);
    }

    /**
     * 批量删除品种信息
     *
     * @param ids 需要删除的品种信息主键
     * @return 结果
     */
    @Override
    public int deleteZsCropVarietyByIds(Long[] ids)
    {
        return zsCropVarietyMapper.deleteZsCropVarietyByIds(ids);
    }

    /**
     * 删除品种信息信息
     *
     * @param id 品种信息主键
     * @return 结果
     */
    @Override
    public int deleteZsCropVarietyById(Long id)
    {
        return zsCropVarietyMapper.deleteZsCropVarietyById(id);
    }
}